package common

import (
	"ginblog/utils/errmsg"
	"github.com/gin-gonic/gin"
	"net/http"
)

func SuccessJson(c *gin.Context, code int, data interface{}) {
	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  errmsg.GetErrMsg(code),
		"data": data,
	})
	return
}

func FailJson(c *gin.Context, code int) {
	SuccessJson(c, code, []interface{}{})
	return
}
